package com.comita.selenium.applogic;

import org.openqa.selenium.By;
import org.openqa.selenium.support.pagefactory.ByChained;
import org.openqa.selenium.support.ui.ExpectedConditions;

public class MailHelper extends DriverBasedHelper {
	
	private ApplicationManager manager;
	
	public String [] inboxFolders = {
			"Inbox", 
			"AJAX", 
			"Announcements", 
			"OpenAccess ORM",
			"Silverlight",
			"WinForms",
			"WPF"};
	
	public MailHelper(ApplicationManager manager){
		super(manager.getWebDriver());
		this.manager = manager;
	}
	
	public void openTelerikWebMail(){
		driver.get(manager.baseUrl);
	}
	
	public void waitAllInboxFolders(){		
		for (int i = 0; i < inboxFolders.length; i++){
			wait.until(ExpectedConditions.elementToBeClickable(
					By.xpath("//span[.='" + inboxFolders[i] + "']")));					
		}		
	}
	
	public void clickAllInboxFolders() throws InterruptedException{
		waitAllInboxFolders();		
		for (int i = 0; i < inboxFolders.length; i++){
			driver.findElement(
					By.xpath("//span[.='" + inboxFolders[i] + "']")).click();					
			wait.until(ExpectedConditions.invisibilityOfElementLocated(
					By.cssSelector("div.raDiv")));
		}
	}
	
}
